﻿/*
* Date：2023/5/24
* Subject：分类控制器
* **/
using Max.PH5_2011A.Domain;
using Max.PH5_2011A.DTO;
using Max.PH5_2011A.IService;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Max.PH5_2011A.API.Controllers.Product
{
    [Route("product/category")]
    [ApiController]
    public class ProductCategoryController : BaseController<ProductCategoryModel>
    {
        IProductCategoryService _serice;
        public ProductCategoryController(IProductCategoryService serice) : base(serice)
        {
            _serice=serice;
        }

        /// <summary>
        /// 分类递归数据
        /// </summary>
        /// <returns></returns>
        [HttpGet("recurision")]
        public IActionResult RecursionCategory()
        {
            ResponseResultDto<dynamic> result = new();
            var list = _serice.RecursionCategory();
            result.Data = list;
            return Ok(result);
        }

        #region admin
        /// <summary>
        /// 后台管理
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        [HttpGet("admin/pages")]
        public IActionResult Query(int pageIndex=1, int pageSize=10)
        {
            ResponseResultDto<dynamic> result = new();
            var list = _serice.Admin_CategoryList();
            //int total = list.Count();
            //list = list.Skip((pageIndex - 1) * pageSize).Take(pageSize);
            result.Data = new { list, total =2};
            return Ok(result);
        }
        #endregion
    }
}
